package com.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bean.Goods;
import com.serve.GoodsService;
import com.serveImple.GoodsServiceImpl;

/**
 * Servlet implementation class GoodsShowServlet
 */
@WebServlet("/GoodsShowServlet")
public class GoodsShowServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public GoodsShowServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		
		String name=request.getParameter("goodsname");
		GoodsService goodsservice=new GoodsServiceImpl();
		int number =0;
		if(name!=null){
			 number=Integer.parseInt(name);				
		}
		Goods goods=goodsservice.showGoods(number);
		
		request.setAttribute("goods", goods);
		
		request.getRequestDispatcher("CommentShowServlet").forward(request, response);
/*		response.sendRedirect("goodsShow.jsp");*/
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request,response);
	}

}
